<?php
/*
	插件概览
	分销插件主要显示哪些数据？
		1、基本数据
		分销订单总数 会员总数 团长总数 
		分销订单近七天增长趋势折线图 会员数近七天增长折线图 团长近七天增长折线图 
		收益总笔数/金额 结算总笔数/金额
		饼状图显示各状态收益数额  饼状图显示各状态结算总笔数/金额
		
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'welcome';
if($_RQ['op']=='welcome'){
	//会员
	$member=array(
		'allfee'=>$this->getsum('redfeelog',array('type'=>0,'uniacid'=>$_SESSION['uniacid']),'fee'),
		'isfee'=>$this->getsum('redfeelog',array('type'=>array(1,2),'uniacid'=>$_SESSION['uniacid']),'fee'),
		'isquanfee'=>$this->getsum('redfeelog',array('type'=>2,'uniacid'=>$_SESSION['uniacid']),'num'),
	);
	$member['lastfee']=$member['allfee']-$member['isfee'];
	$return['htmls'][]=array('type'=>'data','one_num'=>4,'title'=>'总奖金概况','datas'=>array(
		array('title'=>'累计支出总奖金','num'=>1,'data'=>$member['allfee']),
		array('title'=>'抽奖累计消耗金额','num'=>1,'data'=>$member['isfee']),
		array('title'=>'抽奖累计消耗兑换券','num'=>1,'data'=>$member['isquanfee']),
	));
	$member=array(
		'allfee'=>$this->getsum('redfeelog',array('type'=>0,'uniacid'=>$_SESSION['uniacid']),'fee'),
		'isfee'=>$this->getsum('redfeelog',array('type'=>1,'uniacid'=>$_SESSION['uniacid']),'fee'),
	);
	$return['htmls'][]=array('type'=>'data','one_num'=>4,'title'=>'等级总奖金池','datas'=>array(
		array('title'=>'总奖金池','num'=>1,'data'=>$member['allfee']),
		array('title'=>'商品累计支出奖金','num'=>1,'data'=>$member['isfee']),
		array('title'=>'兑换券累计支出数量','num'=>1,'data'=>$member['isnum']),
	));
	$game=pdo_get('jy_weishop_game',array('action'=>'jy_robshop/game/','plugin_name'=>'jy_robshop','uniacid'=>$_SESSION['uniacid']));
	$game['reward']=$game['reward']?json_decode($game['reward'],true):array();
	$leveldatas=array();
	foreach($game['reward'] as $k=>$item){
		$allfee=$this->getsum('redfeelog',array('reward_key'=>$k,'type'=>0,'uniacid'=>$_SESSION['uniacid']),'fee');
		$isfee=$this->getsum('redfeelog',array('reward_key'=>$k,'type'=>array(1,2),'uniacid'=>$_SESSION['uniacid']),'fee');
		$leveldatas[]=array('title'=>'['.$item['level'].']总奖金/已使用','num'=>2,'data'=>array($allfee,$isfee));
	}
	$return['htmls'][]=array('type'=>'data','one_num'=>4,'title'=>'等级总奖金池/已使用','datas'=>$leveldatas);
	set_html('title','总奖金概况');
	exi($return);
}